import 'package:bxultimate/app/router/router_name.dart';
import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/app/theme/gaps.dart';
import 'package:bxultimate/resources/assets.dart';
import 'package:bxultimate/widgets/mk_card_container.dart';
import 'package:bxultimate/widgets/mk_list_cell_item.dart';
import 'package:bxultimate/widgets/mk_load_image.dart';
import 'package:bxultimate/widgets/mk_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'controller.dart';

class OrganizationAccessRegListPage extends StatefulWidget {
  const OrganizationAccessRegListPage({Key? key}) : super(key: key);

  @override
  State<OrganizationAccessRegListPage> createState() =>
      _OrganizationAccessRegListPageState();
}

class _OrganizationAccessRegListPageState
    extends State<OrganizationAccessRegListPage> {
  final controller = Get.find<OrganizationAccessRegListController>();
  final state = Get.find<OrganizationAccessRegListController>().state;

  @override
  Widget build(BuildContext context) {
    return MkPage(
        child: Scaffold(
      backgroundColor: Colors.transparent,
      appBar: TDNavBar(
        title: '出入库登记',
        backgroundColor: Colors.transparent,
      ),
          body: SingleChildScrollView(
            child: _buildBody(),
          ),
    ));
  }
  _buildBody() {
    return Padding(
        padding: EdgeInsets.symmetric(horizontal: AppTheme.iDefaultPadding),
        child: Column(
          children: [
            // ClipRRect(
            //   borderRadius: BorderRadius.circular(8),
            //   child: TDSearchBar(
            //     controller: controller.searchEditController,
            //     placeHolder: '搜索',
            //   ),
            // ),
            Gaps.vGap8,
            Obx(()=>_buildList()),
          ],
        ));
  }

  _buildList() {
    return MkCardContainer(
      padding: EdgeInsets.symmetric(horizontal: AppTheme.iDefaultPadding / 2),
      margin: EdgeInsets.all(0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          ...state.checkPointList.map((e) => MkListCellItem(
            value: '${e.name}',
            press: () {
              Get.toNamed(RouterName.organizationAccessRegQrcode, arguments: e.id);
            },
          )),

         ]
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<OrganizationAccessRegListController>();
    super.dispose();
  }
}
